package com.xms.schema.api.controller;

import com.xms.dependency.XmsDependencyException;
import com.xms.schema.service.attribute.IAttributeDeleterService;
import com.xms.web.framework.controller.ApiBaseController;
import com.xms.web.framework.model.DeleteManyModel;
import com.xms.web.framework.model.JsonResultObject;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;

/**
 * <p>
 * AttributeDeleterController
 * </p>
 *
 * @author migo
 * @since 2021/9/16
 */
@RestController
@RequestMapping("{org}/api/schema/attribute")
public class AttributeDeleterController extends ApiBaseController {
    private IAttributeDeleterService _attributeDeleterService;
    @Autowired
    public void AttributeDeleterController(IAttributeDeleterService attributeDeleterService) {
        _attributeDeleterService = attributeDeleterService;
    }

    @ApiOperation("删除字段")
    @PostMapping("deletebyid")
    public JsonResultObject deleteById(@RequestBody DeleteManyModel model) throws SQLException, XmsDependencyException {
        if(_attributeDeleterService.deleteById(model.RecordId)){
            return JDeleteSuccess();
        }
        return JDeleteFailure();
    }
}
